CREATE TABLE [dbo].[tb_DETALLESDELINDICADOR]
(
[idDetalleIndicador] [int] NOT NULL IDENTITY(1, 1),
[Descripcion] [varchar] (150) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Observaciones] [varchar] (350) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Monto] [int] NULL,
[Indicador] [int] NULL,
[Cantidad] [int] NULL,
[Tipo] [int] NULL,
[Accion] [int] NULL,
[Usuario] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
CREATE TRIGGER [dbo].[cambiarno] ON [dbo].[tb_DETALLESDELINDICADOR] 

FOR  UPDATE, DELETE 
AS


if (SELECT usuario FROM Inserted ) <> system_user
 BEGIN
	ROLLBACK transaction 
	RAISERROR('Solo el responsable del dato puede modificarlo.', 16,1)
          
END


GO
ALTER TABLE [dbo].[tb_DETALLESDELINDICADOR] ADD CONSTRAINT [PK_tb_DetallesDelIndicador] PRIMARY KEY CLUSTERED  ([idDetalleIndicador]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[tb_DETALLESDELINDICADOR] WITH NOCHECK ADD CONSTRAINT [FK_tb_DETALLESDELINDICADOR_tb_ACCIONES] FOREIGN KEY ([Accion]) REFERENCES [dbo].[tb_ACCIONES] ([tab_accion_id])
GO
ALTER TABLE [dbo].[tb_DETALLESDELINDICADOR] WITH NOCHECK ADD CONSTRAINT [FK_tb_DETALLESDELINDICADOR_tb_INDICADOR] FOREIGN KEY ([Indicador]) REFERENCES [dbo].[tb_INDICADOR] ([indicador_id])
GO
EXEC sp_addextendedproperty N'MS_Description', N'(suser_sname())', 'USER', N'dbo', 'TABLE', N'tb_DETALLESDELINDICADOR', 'COLUMN', N'Usuario'
GO
